//package com.example.stock.service;
//
//import cn.hutool.core.lang.Console;
//import cn.hutool.json.JSONUtil;
//import com.example.stock.entity.Stock;
//import com.example.stock.mapper.StockMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.PostConstruct;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.function.Function;
//import java.util.stream.Collectors;
//
//@Service
//public class YangBaoyinService {
//
//    @Autowired
//    private IStockService stockService;
//
//    @Autowired
//    private StockMapper stockMapper;
//
//    @PostConstruct
//    public void calc(){
//        List<Stock> stocks1 = stockService.listByCalcTimeAndCalcType("2024-12-26", 3);
//        List<Stock> stocks2 = stockService.listByCalcTimeAndCalcType("2024-12-27", 3);
//        List<Stock> stocks3 = stockService.listByCalcTimeAndCalcType("2024-12-30", 3);
//        Map<String, Stock> map1 = stocks1.stream().collect(Collectors.toMap(Stock::getCode, Function.identity()));
//        Map<String, Stock> map2 = stocks2.stream().collect(Collectors.toMap(Stock::getCode, Function.identity()));
//        Map<String, Stock> map3 = stocks3.stream().collect(Collectors.toMap(Stock::getCode, Function.identity()));
//        List<Stock> resArr = new ArrayList<>();
//        List<Stock> zhangArr = new ArrayList<>();
//        List<Stock> dieArr = new ArrayList<>();
//        map1.forEach((k,v)->{
//            Stock stock = map2.get(k);
//            //阳包阴
//            if(stock.getPriceMin()>v.getPriceMax()  && !stock.getPriceNow().equals(stock.getHighLimit()) && stock.getChangePercent()>1
//             ){
//                resArr.add(stock);
//                if(map3.get(k).getPriceNow()>stock.getPriceNow()) {
//                    zhangArr.add(stock);
//                }else{
//                    dieArr.add(stock);
//                }
//            }
//        });
//
//        zhangArr.forEach((obj)->{
//            Console.log(map1.get(obj.getCode()).getChangePercent()+","+obj.getChangePercent()+","+map3.get(obj.getCode()).getChangePercent()+"上涨数据："+ JSONUtil.toJsonStr(obj));
//        });
//        dieArr.forEach((obj)->{
//            Console.log(map1.get(obj.getCode()).getChangePercent()+","+obj.getChangePercent()+","+map3.get(obj.getCode()).getChangePercent()+"下跌数据："+ JSONUtil.toJsonStr(obj));
//        });
//    }
//
//
//}
